package com.og.ouroa.controller;

import com.og.ouroa.common.annotations.EnableLoginHandle;
import com.og.ouroa.common.result.R;
import com.og.ouroa.pojo.entity.UserInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;

@RestController
@RequestMapping("/admin")
@Slf4j
@CrossOrigin
@Api(tags = "连接测试")
public class TestController {


    @EnableLoginHandle(identity = UserInfo.TEACHER)
    @ApiOperation("测试")
    @GetMapping("/test/{i}")
    public R test(@ApiParam(value = "测试参数",required = true) @PathVariable Integer i){
        System.out.println("测试进入参数"+i);
        return R.ok().message("测试").data("接收数据",i);


    }
    @EnableLoginHandle(identity = UserInfo.STUDENT)
    @GetMapping("/testList/{i}")
    @ApiOperation("集合测试")
    public R testist(@ApiParam(value = "测试参数",required = true) @PathVariable Integer i){
        System.out.println("进入list测试参数"+i);
        ArrayList<Integer> integers = new ArrayList<>();
        integers.add(i);
        return R.ok().message("测试").data("结果list",integers);


    }

    @GetMapping("/testMap/{i}")
    @ApiOperation("Map测试")
    public R testMap(@ApiParam(value = "测试参数",required = true) @PathVariable Integer i){
        System.out.println("进入map测试,参数"+i);
        HashMap<String, Integer> map = new HashMap<>();

        map.put("数据",i);
        return R.ok().message("测试").data("结果map",map);


    }
}
